<%@include file="includes.jsp" %>

<div>
    <div style="margin-left: 5px; margin-right: 5px">
                <table rules="all" border="1" id="proto" style="background-color: #ffffff">
                    <thead>
                      <tr valign="middle" style="height: 50px">
                        <td style="width:140px"></td>
                        <c:forEach items="${gameContext.tasks}" var="task">
                            <td align="center" style="width:180px" id="${task.id}" class="tsk-marker">
                                <form action="ch_enable.htm" name="task_${task.id}">
                                    <div style="font: bold 8pt sans-serif">
                                        <div class="small-text" style="width: 150px; color: #000000">
                                            ${task.name}
                                        </div>
                                    </div>
                                    <div  style="font: bold 8pt sans-serif">
                                        <div class="small-text">
                                            <c:if test="${task.enabled}">
                                                <span style="color: #666666; font-style: normal">
                                                    <spring:message code="messages.task.enabled"/>
                                                </span>
                                             </c:if>
                                             <c:if test="${!task.enabled}">
                                                <span style="color: #ff3399; font-style: normal;">
                                                    <spring:message code="messages.task.disabled"/>
                                                </span>
                                             </c:if>
                                        </div>
                                    </div>
                                    <input type="hidden" value="${task.id}" name="task_id"/>
                                </form>
                            </td>
                        </c:forEach>
                      </tr>
                    </thead>
                    <tbody>
                    <c:forEach items="${gameContext.positions}" var="position">
                      <tr>
                        <td class="tm-marker" id="${position.team.id}">
                            <div  style="font: bold 8pt sans-serif">
                                <div class="small-text" style="color: #000000">${position.team.name}</div>
                            </div>
                            <div class="guessed-text"><div class="small-text">
                                <spring:message code="messages.gs.quessed"/>:&nbsp;${position.guessed}
                            <br></div></div>
                            <div class="timeout-text"><div class="small-text">
                                <spring:message code="messages.gs.timeout"/>:&nbsp;${position.timeout}
                            <br/></div></div>
                            <div class="rejected-text"><div class="small-text">
                                <spring:message code="messages.gs.rejected"/>:&nbsp;${position.rejected}
                            </div></div>
                        </td>
                        
                        <c:forEach items="${gameContext.tasks}" var="task">
                                    <c:set var="obtainedTask" value=""/>
                                    <c:if test="${position.obtainedTask.task.id eq task.id}">
                                        <c:set var="obtainedTask" value="${position.obtainedTask}"/>
                                    </c:if>
                                    <c:if test="${! empty position.obtainedTasks[task.id]}">
                                        <c:set var="obtainedTask" value="${position.obtainedTasks[task.id]}"/>
                                    </c:if>
                                    <c:if test="${! empty obtainedTask}">
                                        
                                        <c:if test="${! empty obtainedTask.start}">
                                            <c:set var="outputStyle" value="current-task"/>
                                            <c:if test="${obtainedTask.firstHintState}">
                                                <c:set var="outputStyle" value="firstHint"/>
                                            </c:if>
                                            <c:if test="${obtainedTask.secondHintState}">
                                                <c:set var="outputStyle" value="secondHint"/>
                                            </c:if>
                                            <c:if test="${obtainedTask.finishedState}">
                                                <c:set var="resultLabel" value="messages.ts.guessed"/>
                                                <c:set var="outputStyle" value="guessed"/>
                                                <c:if test="${obtainedTask.timeoutResult}">
                                                    <c:set var="outputStyle" value="timeout"/>
                                                    <c:set var="resultLabel" value="messages.ts.time_over"/>
                                                </c:if>
                                                <c:if test="${obtainedTask.rejectedResult}">
                                                    <c:set var="outputStyle" value="rejected"/>
                                                    <c:set var="resultLabel" value="messages.ts.rejected"/>
                                                </c:if>
                                                <c:if test="${obtainedTask.stopGameResult}">
                                                    <c:set var="outputStyle" value="stop-game"/>
                                                    <c:set var="resultLabel" value="messages.ts.stop_game"/>
                                                </c:if>
                                            </c:if>
                                            <td class="${outputStyle} obt-marker" id="${obtainedTask.task.id}">
                                                <div style="color: #000000">
                                                <div style="font: bold 8pt sans-serif">
                                                    <div class="small-text">
			                                             <spring:message code="messages.ts.obtained"/>&nbsp;<joda:format value="${obtainedTask.start}" pattern="HH:mm"/>
			                                        </div>
			                                    </div>
                                                <c:if test="${! empty obtainedTask.firstHint}">
	                                               <div style="font: bold 8pt sans-serif">
	                                                    <div class="small-text">
                                                            <spring:message code="messages.ts.first_hint"/>&nbsp;<joda:format value="${obtainedTask.firstHint}" pattern="HH:mm"/>
	                                                    </div>
	                                                </div>
                                                </c:if>
                                                <c:if test="${! empty obtainedTask.secondHint}">
                                                   <div style="font: bold 8pt sans-serif">
                                                        <div class="small-text">
                                                            <spring:message code="messages.ts.second_hint"/>&nbsp;<joda:format value="${obtainedTask.secondHint}" pattern="HH:mm"/>
                                                        </div>
                                                    </div>
                                                </c:if>
                                                <c:if test="${obtainedTask.finishedState}">
                                                   <div style="font: bold 8pt sans-serif">
                                                        <div class="small-text">
                                                            <spring:message code="${resultLabel}"/>&nbsp;<joda:format value="${obtainedTask.finished}" pattern="HH:mm"/>
                                                        </div>
                                                    </div>
                                                </c:if>
                                                </div>
                                            </td>
                                        </c:if>
                                    </c:if>
                                    <c:if test="${empty obtainedTask}">
                                    <td></td>
                                    </c:if>
                        </c:forEach>
                      </tr>
                    </c:forEach>
                    </tbody>
                    </table>

    </div>
</div>